package com.example.server.web.controller;


import com.example.server.web.domain.CourseClassTeacher;
import com.example.server.web.domain.RespBean;
import com.example.server.web.domain.dto.CourseClassTeacherParamDto;
import com.example.server.web.domain.page.PageQueryDto;
import com.example.server.web.service.CourseClassTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  课程-班级-教师 前端控制器
 * </p>
 *
 * @author 作者
 * @since 2023-04-04
 */
@RestController
@RequestMapping("/course-class-teacher")
@Api(tags = {"课程-班级-教师接口"})
public class CourseClassTeacherController {
    @Autowired
    private CourseClassTeacherService courseClassTeacherService;

    @ApiOperation("关联课程-班级-教师")
    @PostMapping("/add")
    public RespBean add(@RequestBody CourseClassTeacher courseClassTeacher){
        courseClassTeacherService.add(courseClassTeacher);
        return RespBean.success("添加成功");
    }

    @ApiOperation("通过班级id或者教师id查询课程（模糊查询可以通过年份去筛选）")
    @GetMapping("/getPage")
    public RespBean getPage(CourseClassTeacher courseClassTeacher, PageQueryDto pageQueryDto){
        Map map = courseClassTeacherService.getPage(courseClassTeacher, pageQueryDto);
        return RespBean.success("查询成功",map);
    }

    @ApiOperation("通过用户id查询课程（模糊查询可以通过年份去筛选）")
    @GetMapping("/getPageByStuId")
    public RespBean getPageByStuId(Long studentId, PageQueryDto pageQueryDto){
        Map map = courseClassTeacherService.getPageByStuId(studentId, pageQueryDto);
        return RespBean.success("查询成功",map);
    }

    @ApiOperation("查询出所有课程关联的分页信息")
    @GetMapping("/getAllToPage")
    public RespBean getAllToPage(CourseClassTeacherParamDto paramDto, PageQueryDto pageQueryDto){
        Map map = courseClassTeacherService.getAllToPage(paramDto, pageQueryDto);
        return RespBean.success("查询成功",map);
    }

}
 